Skip to content

[13.x] Fix TrustProxies at:* when multiple proxies are used#60726

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
mattford:bug/60725
Jul 14, 2026
Merged

[13.x] Fix TrustProxies at:* when multiple proxies are used#60726
taylorotwell merged 3 commits into
laravel:13.xfrom
mattford:bug/60725

Conversation

@mattford

@mattford mattford commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Update TrustProxies to trust a catchall address for IPv4 and IPv6 when trust all proxies is specified

Currently, only the remote address is trusted when using TrustProxies:*. If there are multiple proxies this results in the most recent proxy being treated as the original client IP.

There are tests for this however they were incorrect, treating the last IP in the X-Forwarded-For or Forwarded header list as the original, however it should be the first one (https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For)

Resolves #60725

Update TrustProxies to add all intermediate IP addresses to trusted list
@github-actions

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@mattford
mattford marked this pull request as ready for review July 10, 2026 10:43
@mattford mattford changed the title Correct ordering of forwarded IP addresses in test [13.x] Fix TrustProxies at:* when multiple proxies are used Jul 10, 2026
Comment thread src/Illuminate/Http/Middleware/TrustProxies.php Outdated
…l address instead of gathering all IPs from the request
* @param \Illuminate\Http\Request $request
* @return void
*/
protected function setTrustedProxyIpAddressesToTheCallingIp(Request $request)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have kept this method name the same for now to preserve the contract for anyone extending this class however I am aware it now doesn't reflect what it's actually doing

@taylorotwell
taylorotwell merged commit e4f6d20 into laravel:13.x Jul 14, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TrustProxies with at: * does not work correctly when request has passed through multiple proxies

3 participants